Skip to content

fix: warn and exit 1 when --since matches no migrations, note skipped graph checks#52

Merged
croc100 merged 2 commits into
mainfrom
fix/since-empty-match-warning
Jun 8, 2026
Merged

fix: warn and exit 1 when --since matches no migrations, note skipped graph checks#52
croc100 merged 2 commits into
mainfrom
fix/since-empty-match-warning

Conversation

@croc100

@croc100 croc100 commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Problems

Two related issues with mrt check --since:

#36: Passing an unknown or unanchored revision silently returned "No rollback risks detected" (exit 0). Users could mistake this for a clean result when the filter simply matched nothing.

#34: When --since is valid, graph-level checks (orphan detection, data-hole analysis) are already skipped — but there was no indication of this. Users had no way to know they needed a separate full-history run.

Fix

  • If --since <rev> resolves to an empty set, exit 1 immediately with:
    Warning: --since a1b2c3d4 matched no migrations. Check the revision ID and try again.
    
  • If --since <rev> is valid, print the migration count and a note:
    --since 001: checking 1 migration(s) after this point
    Note: graph checks (orphan, data-hole detection) skipped — run without --since for full analysis.
    

Tests

Added three tests covering:

  • Unknown revision exits 1 with warning message
  • Valid revision shows graph-checks-skipped note
  • Valid revision shows migration count

Fixes #36, fixes #34

croc100 added 2 commits June 8, 2026 19:17
Previously, mrt fix silently returned 'No fix needed' for Django migrations
containing AddField NOT NULL, AlterField, RenameField, or RenameModel — even
though mrt check would flag those as warnings. This was misleading.

Now mrt fix detects these unsupported operations and exits 1 with a clear
message explaining which operations were found and that they require manual
intervention. Null-safe AddField and operations with defaults are correctly
still treated as 'no fix needed'.

Fixes #37
… graph checks

Two issues addressed:

- #36: --since with an unknown or unanchored revision previously returned
  'No rollback risks detected' (exit 0), giving a false sense of safety.
  Now exits 1 with a clear warning: '--since <rev> matched no migrations'.

- #34: when --since is valid, print the count of migrations being checked
  and a note that graph checks (orphan, data-hole) are skipped so users
  know to run a full check separately.

Fixes #36, fixes #34
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 70.27027% with 11 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pytest_mrt/adapters/django_fixer.py 65.21% 3 Missing and 5 partials ⚠️
pytest_mrt/commands/check.py 70.00% 2 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@croc100 croc100 merged commit aa59bff into main Jun 8, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants